/*
 * @(#) BaseActionForm.java  1.0  2004-3-10
 *
 * Copyright 2003 by LongTop Corporation.
 * 2669 XieTu Road, ShangHai, PRC 200030
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * LongTop Corporation ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with LongTop.
 */

package com.cnc.bas.web;

import com.cnc.bas.util.Constants;
import com.cnc.ssm.UserInfo;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorForm;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Du bf
 * @version 1.0  2004-3-10
 */
public class BasActionForm extends ValidatorForm {

    public UserInfo operator = null;

    private String action = null;

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    protected void addErrorIfStringEmpty(ActionErrors errors, String key, String value) {
        if (errors == null) errors = new ActionErrors();
        if (value == null || value.trim().length() < 1) {
            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(key, value));
        }
    }

    public void reset(ActionMapping mapping, HttpServletRequest request) {
        operator = (UserInfo) request.getSession().getAttribute(Constants.USER_KEY);
    }
}